<?php
require("../../funcionesDB.php");
if(isset($_REQUEST['axn'])) {
	if($_REQUEST['axn']=='insert_news') {
		$newsInsertString = "insert into noticias (title,body,status) values ('".$_REQUEST['title']."','".$_REQUEST['FCKeditor1']."','".$_REQUEST['status']."')";
		$newsInsertQuery = dbInsert($newsInsertString);
	} else if($_REQUEST['axn']=='update_news') {
		$cleanTagNewsString = "delete from tags_noticias where noticia_id=".$_REQUEST['noticia_id'];
		$cleanTagNewsQuery = dbInsert($cleanTagNewsString);
		
		$tok = strtok ($_REQUEST['tagInputHidden']," ");
		while ($tok !== false) {
			$appendTagNewsString = "insert into tags_noticias (tag_id,noticia_id) values (".$tok.",".$_REQUEST['noticia_id'].")";
			$appendTagNewsQuery = dbInsert($appendTagNewsString);
			$tok = strtok(" \n\t");
		}	
		$newsUpdateString = "update noticias set title='".$_REQUEST['title']."', body='".$_REQUEST['FCKeditor1']."', status='".$_REQUEST['status']."' where noticia_id=".$_REQUEST['noticia_id'];
		$newsUpdateQuery = dbInsert($newsUpdateString);
	} else if($_REQUEST['axn']=='activate_news') {
		$newsUpdateString = "update noticias set status='A' where noticia_id=".$_REQUEST['noticia_id'];
		$newsUpdateQuery = dbInsert($newsUpdateString);
	} else if($_REQUEST['axn']=='inactivate_news') {
		$newsUpdateString = "update noticias set status='I' where noticia_id=".$_REQUEST['noticia_id'];
		$newsUpdateQuery = dbInsert($newsUpdateString);
	} else if($_REQUEST['axn']=='set_home') {
		$newsUpdateString = "update home_config set noticia_id=".$_REQUEST['noticia_id']." where type='H' and status='A'";
		$newsUpdateQuery = dbInsert($newsUpdateString);
	}
	header('Location:../index.php?admin=noticias');
}


?>